package org.finesys.chat.core.base.document.loader;

import lombok.extern.slf4j.Slf4j;
import org.finesys.chat.core.base.document.Document;
import org.finesys.chat.core.base.document.parser.DocumentParser;
import org.finesys.chat.core.base.document.parser.TextDocumentParser;
import org.finesys.chat.core.base.document.source.ClassPathSource;
import org.finesys.common.core.util.Utils;

@Slf4j
public class ClassPathDocumentLoader {

    private static final DocumentParser DOCUMENT_PARSER = Utils.getOrDefault(DocumentParserLoader.loadDocumentParser(), new TextDocumentParser());


    public static Document loadDocument(String className) {
        return load(className, DOCUMENT_PARSER);
    }

    public static Document load(String className, DocumentParser documentParser) {
        ClassPathSource classPathSource = ClassPathSource.from(className);
        return DocumentLoader.load(classPathSource, documentParser);
    }
}
